import request from '@/utils/request'

/**
 * 获取帖子列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getPostList(params) {
  return request({
    url: '/forum/post/list',
    method: 'get',
    params
  })
}

/**
 * 获取帖子详情
 * @param {string} id - 帖子ID
 * @returns {Promise}
 */
export function getPostDetail(id) {
  return request({
    url: `/forum/post/${id}`,
    method: 'get'
  })
}

/**
 * 删除帖子
 * @param {string} id - 帖子ID
 * @returns {Promise}
 */
export function deletePost(id) {
  return request({
    url: `/forum/post/${id}`,
    method: 'delete'
  })
}

/**
 * 审核帖子
 * @param {string} id - 帖子ID
 * @param {Object} data - 审核信息
 * @returns {Promise}
 */
export function reviewPost(id, data) {
  return request({
    url: `/forum/post/${id}/review`,
    method: 'put',
    data
  })
}

/**
 * 置顶/取消置顶帖子
 * @param {string} id - 帖子ID
 * @param {boolean} sticky - 是否置顶
 * @returns {Promise}
 */
export function stickyPost(id, sticky) {
  return request({
    url: `/forum/post/${id}/sticky`,
    method: 'put',
    data: { sticky }
  })
}

/**
 * 精华/取消精华帖子
 * @param {string} id - 帖子ID
 * @param {boolean} featured - 是否精华
 * @returns {Promise}
 */
export function featuredPost(id, featured) {
  return request({
    url: `/forum/post/${id}/featured`,
    method: 'put',
    data: { featured }
  })
}

/**
 * 获取评论列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getCommentList(params) {
  return request({
    url: '/forum/comments',
    method: 'get',
    params
  })
}

/**
 * 获取评论详情
 * @param {string} id - 评论ID
 * @returns {Promise}
 */
export function getCommentDetail(id) {
  return request({
    url: `/forum/comments/${id}`,
    method: 'get'
  })
}

/**
 * 回复评论
 * @param {Object} data - 回复内容
 * @returns {Promise}
 */
export function replyComment(data) {
  return request({
    url: '/forum/comments/reply',
    method: 'post',
    data
  })
}

/**
 * 更新评论状态
 * @param {string} id - 评论ID或ID数组
 * @param {number} status - 状态值
 * @returns {Promise}
 */
export function updateCommentStatus(id, status) {
  return request({
    url: `/forum/comments/${id}/status`,
    method: 'put',
    data: { status }
  })
}

/**
 * 删除评论
 * @param {string} id - 评论ID或ID数组
 * @returns {Promise}
 */
export function deleteComment(id) {
  return request({
    url: `/forum/comments/${id}`,
    method: 'delete'
  })
}

/**
 * 批量删除评论
 * @param {Array} ids - 评论ID数组
 * @returns {Promise}
 */
export function batchDeleteComments(ids) {
  return request({
    url: '/forum/comments/batch',
    method: 'delete',
    data: { ids }
  })
}

/**
 * 审核评论
 * @param {string} id - 评论ID
 * @param {Object} data - 审核信息
 * @returns {Promise}
 */
export function reviewComment(id, data) {
  return request({
    url: `/forum/comment/${id}/review`,
    method: 'put',
    data
  })
}

/**
 * 获取论坛统计数据
 * @returns {Promise}
 */
export function getForumStatistics() {
  return request({
    url: '/forum/statistics',
    method: 'get'
  })
} 